#include "sys.h"
u8 showMode;
u8 workMode = 1;
u8 timeMode = 4;

void key_action()
{

	if(S7 == 0)
	{
		delay1ms(5);
		while(!S7);
		TR1 = ~TR1;
	}
	
	if(S6 == 0)
	{
		delay1ms(5);
		while(!S6);
		showMode++;
		if(showMode == 3)
		{
			writeAt24c02(workMode-1,timeMode);
			delay1ms(2);
			showMode = 0;
		}
	}
	
	if(S5 == 0)
	{
		delay1ms(5);
		while(!S5);
		if(showMode == 1)
		{
			workMode++;
			if(workMode == 5)
			{
				workMode = 4;
			}
		}else if(showMode == 2)
		{
			timeMode += 1;
			if(timeMode >= 12)
			{
				timeMode = 12;
			}
		}
	}
	
	if(S4 == 0)
	{
		delay1ms(5);
		while(!S4);
		if(showMode == 1)
		{
			workMode--;
			if(workMode == 0)
			{
				workMode = 1;
			}
		}else if(showMode == 2)
		{
			timeMode -= 1;
			if(timeMode == 3)
			{
				timeMode = 4;
			}
		}
	}
}


